<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div>
    <div class="father">
      <div class="box" :class="currentIndex==index?'active':''" :key="item.id" v-for="(item,index) in list" @click="fn(index)">{{item.id}}</div>
    </div>
  </div>
</template>

<script>


export default {
  data() {
    return {
      active:true,
      //div当前索引为0
      currentIndex:0,
      list:[
        {id:1},
        {id:2},
        {id:3},
      ]
    };
  },

  methods: {
    fn(index){
      this.currentIndex=index
      console.log(index);
      
    }
  },
};
</script>

<style scoped>
.box {
  border: 1px solid #333;
  width: 250px;
  height: 250px;
}
.father {
  display: flex;
}
.active {
  background-color: #087;
}
</style>